package kr.hkit.powerjava.coffee;

import javax.swing.JPanel;
import javax.swing.JLabel;

import java.awt.Font;

import javax.swing.SwingConstants;
import javax.swing.JScrollPane;
import javax.swing.BoxLayout;

import java.awt.BorderLayout;

import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;

public class PanelOutput extends JPanel {
	private JLabel lblNewLabel;
	private JScrollPane scrollPane;
	private JTable table;

	/**
	 * Create the panel.
	 */
	public PanelOutput(String txt) {

		initialize(txt);
	}
	private void initialize(String txt) {
		setLayout(new BorderLayout(0, 0));
		
		lblNewLabel = new JLabel(txt);
		lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
		lblNewLabel.setFont(new Font("굴림", Font.PLAIN, 20));
		add(lblNewLabel, BorderLayout.NORTH);
		
		scrollPane = new JScrollPane();
		add(scrollPane, BorderLayout.CENTER);
		
		String[] colNames = { "순위", "제품코드", "제품명", "제품단가", "판매수량", "공급가액", "부가세액", "판매금액", "마진율", "마진액" };
		TableModel model = new DefaultTableModel(colNames, 0) {

			@Override
			public Class<?> getColumnClass(int columnIndex) {
				return getValueAt(0, columnIndex).getClass();
			}// 첫번째 행이 들어왔을 때 그 열의 데이터 타입을 결정함
		};
		
		table = new JTable(model);
		scrollPane.setViewportView(table);
	}

}
